The present invention relates to computer-implemented methods for brush based warping including causing reflection effects in an image.
Computer painting programs allow the user to manipulate an electronic image with an onscreen xe2x80x9cbrushxe2x80x9d controlled by an input device such as a mouse. One such program is Goo, available from MetaTools, Inc., 6303 Carpinteria Ave., Carpinteria, Calif., 93013.
The user may typically select from among a variety of brush shapes, e.g., circle, square, or single pixel. The user drags the brush along a xe2x80x9ctrajectoryxe2x80x9d from one location to another within the image, thereby defining an xe2x80x9cenvelope.xe2x80x9d Pixels within the envelope are affected by the operation of the brush.
One type of brush allows a user to xe2x80x9cpaintxe2x80x9d colors and textures into the envelope. The paintbrush replaces the pixels in the envelope with the image of the brush.
Another type of brush allows the user to xe2x80x9cmovexe2x80x9d portions of the image within the envelope, creating a warping effect. For example, a xe2x80x9cstickyxe2x80x9d brush moves pixels from the starting point of the envelope to its end. A xe2x80x9cslippingxe2x80x9d brush moves the pixels from the starting point a distance less than, but proportional to, the length of the trajectory. Other warping brush effects are bloat, pucker, and twirl.
In general, in one aspect, the invention features a method and computer program product for generating a warping effect in an image having a plurality of regions, each associated with a distortion vector. The method includes defining a path segment vector in response to user movement of a brush cursor; modifying one or more distortion vectors having originations covered by the cursor based on the path segment vector; and repeating defining and modifying to produce a warping effect.
Particular implementations can include one or more of the following features.
The method includes sampling a source image using the distortion vectors to produce a destination image.
Each distortion vector ends at a mesh point in a distortion mesh, and modifying distortion vectors includes multiplying the path segment vector by a predetermined matrix, thereby producing a product vector; interpolating each distortion vector between mesh points that surround the end of the product vector, thereby producing an interpolated vector; and combining the product vector and the interpolated vector.
The direction of the path segment vector is opposite to the direction of movement of the brush cursor.
Multiplying can cause the magnitude of the product vector to be substantially twice the magnitude of the path segment vector.
Multiplying can cause the direction of the product vector to differ from the direction of the path segment vector by substantially 90 degrees.
The interpolation for the distortion vector can be linear, bilinear or of higher order.
Defining includes defining a plurality of path segment vectors in response to user manipulation of a brush cursor, wherein the magnitude of each path segment vector depends on its location within the brush cursor; and modifying includes modifying a distortion vector using the nearest path segment vector.
The method includes dividing the image into a frozen area and a unfrozen area by a boundary in response to user input; moving the cursor from the frozen area into the unfrozen area in response to user input; and modifying the distortion vectors in the unfrozen region covered by the cursor to produce a reflection effect based on a portion of the frozen area.
The distortion vectors form a distortion vector field, and the method includes generating one or more further distortion vector fields; modifying each distortion vector field using a different time-varying function; combining the resulting distortion vector fields to produce a time-varying distortion vector field; and repeatedly sampling the source image using the time-varying distortion vector field to produce an image having an animated image.
The sum of the time-varying functions is one at any given time.
Each of the time-varying functions is continuous.
Advantages that can be seen in implementations of the invention include one or more of the following. A mirror brush is provided that creates a reflection effect in an image. The reflection effect is warped to look like a reflection on a water surface with waves. The warped reflection effect can also be animated with very little processing expense to produce an animated water reflection effect. An artist can move the brush to produce different types of waves. To the artist, effect feels like xe2x80x9cpainting the wavesxe2x80x9d on which the image is reflected.